Skip to content

Fix #11654: create new symbol for stdlib patches #11803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 22, 2021

Conversation

liufengyun
Copy link
Contributor

Fix #11654: create new symbol for stdlib patches

[test_windows_full]

@liufengyun liufengyun force-pushed the fix-11654 branch 2 times, most recently from d4b9537 to a33db77 Compare March 18, 2021 12:57
@liufengyun liufengyun force-pushed the fix-11654 branch 2 times, most recently from 224a0da to 6219910 Compare March 18, 2021 13:48
@liufengyun liufengyun marked this pull request as ready for review March 19, 2021 01:38
@liufengyun liufengyun requested review from smarter and odersky March 19, 2021 07:08
@liufengyun liufengyun added this to the 3.0.0-RC2 milestone Mar 19, 2021
patch.denot = patch.denot.copySymDenotation(owner = denot.symbol)
patch
else
// change `info` which might contain reference to the patch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use a TreeTypeMap to map the info instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean for the inline tree in the annotation? It's quite complex -- we need to create a copy of all local symbols (e.g. for type, term symbols, symbols in the function body, etc.) and rewire them.

For non-inline symbols, we make strong assumptions on symbol.info, which seems to be simpler.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant for both, but I don't know if TreeTypeMap works on inline defs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a principled way to do this --- a map needs to make assumptions about from and to. We will not make fewer assumptions and the code will be complex.

def recurse(patch: Symbol) = patch.is(Module) && scope.lookup(patch.name).exists

def makeClassSymbol(patch: Symbol, parents: List[Type], selfInfo: TypeOrSymbol) =
newClassSymbol(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we use patch.copy(...) here? Would that not be shorter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason is that info and symbol depend on each other, and Symbol.copy does not support that.

name = patch.name.asTypeName,
flags = patch.flags,
// need to rebuild a fresh ClassInfo
infoFn = cls => ClassInfo(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it not be shorter to use derivedClassInfo here?

Copy link
Contributor Author

@liufengyun liufengyun Mar 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does not make much difference, as we change all fields here except parents. On the other hand, using the constructor makes the implicit assumptions explicit and clear here.

Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, makes sense. Thanks for the explanations!

@odersky odersky merged commit 3d5b4c8 into scala:master Mar 22, 2021
@odersky odersky deleted the fix-11654 branch March 22, 2021 09:16
@Kordyjan Kordyjan modified the milestones: 3.0.0-RC2, 3.0.0 Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test_windows_full in the CI is broken: pickling difference in stdlibPatches
4 participants